#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QSerialPortInfo>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    void timerEvent(QTimerEvent* event);//更新端口

    void USART();

private slots:
    void on_pushButton_clearReceive_clicked();

    void on_pushButton_clearSend_clicked();

    void on_pushButton_serial_clicked();

    void on_pushButton_send_clicked();

    void on_checkBox_send_clicked(bool checked);


    void on_pushButton_saveFile_clicked();

    void on_pushButton_openFile_clicked();


private:
    Ui::Widget *ui;

    QSerialPort* serialPort;    //端口
    QVector<QString> comPorts;  //存放端口的数组

    QTimer* timerSend;  //用于定时发送
    int writeCountTotal = 0;//总共发送数据
    int readCountTotal = 0;//总共接收数据

    QTimer* timerSystem;  //用于刷新获取系统时间
};
#endif // WIDGET_H
